#!/usr/bin/python3
# -*- coding:utf-8 -*-
# __author__ == taoyulong2018@gmail.com
# __time__ == 2023/8/23 9:49
# ===========================================
#       题目名称： 27. 移除元素
#       题目地址： https://leetcode.cn/problems/remove-element/description/
#       题目描述： https://note.youdao.com/s/RRXNSXjR
# ===========================================


class Solution:
    def removeElement(self, nums, val):
        cur_index = 0
        while cur_index < len(nums):
            if nums[cur_index] == val:
                del nums[cur_index]
            else:
                cur_index += 1
        return len(nums)


if __name__ == '__main__':
    s = Solution()
    # 2
    print(s.removeElement(nums=[3, 2, 2, 3], val=3))
    # 5
    print(s.removeElement(nums=[0, 1, 2, 2, 3, 0, 4, 2], val=2))
